%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% APPENDIX: PRESENT MEDIAN LAND-USE REGRESSION TABLES

% "DEFORESTATION IN THE AMAZON:
% A UNIFIED FRAMEWORK FOR ESTIMATION AND POLICY ANALYSIS"

% by Eduardo Souza-Rodrigues

% This version: November 2018

% OBSERVATIONS: 
% Run this program after running "dem_def_reg.m"

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% (A) LOAD DATA & SET LABELS

% Load Estimated Coefficients and Standard Errors (calculated in "dem_def_reg.m")
load beta_ivqr_farm_1;
load beta_ivqr_farm_2;
load beta_ivqr_farm_3;
load beta_ivqr_farm_4;

% Set of Covariates (Model Specification):
if model == 0
    
    % Main Specification    
    Names = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Fines','Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA','Constant'};
        
elseif model == 1
    
    % No Population
    Names = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Prop Land Title',...
            'Fines','Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA','Constant'};
       
elseif model == 2
    
    % No land title proxy
    Names = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population',...
            'Fines','Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA','Constant'};
    
elseif model == 3
    
    % No distance to ibama, nor fines
    Names = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'W Population','W Mining','W Powerplant','W Dist to PA','Constant'};
    
elseif model == 4
    
    % No distance to ibama
    Names = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Fines','W Population','W Mining','W Powerplant','W Dist to PA','Constant'};

elseif model == 5
    
    % No Fines
    Names = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA','Constant'};

elseif model == 6
   
    % No Spatially Lagged Regressors
    Names = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Fines','Dist to Ibama','Constant'};
    
end


%% (B) SHOW ESTIMATED RESULTS

disp('----------------------------------------------------------------------------')
disp('----------------------------------------------------------------------------')
disp('APPENDIX: MEDIAN LAND-USE REGRESSIONS, LOGIT MODEL - COEFFICIENTS ON ALL REGRESSORS')       
disp('SMALL FARMS, MEDIAN REGRESSION')
table(round(beta_ivqr_farm_1(:,3),4),round(beta_ivqr_farm_1(:,8),4),round([beta_ivqr_farm_1(:,3+15),beta_ivqr_farm_1(:,3+20)],4),...
    'VariableNames',{'Coeff','se','Conf_Interval_95'},'RowNames',Names)
pause
disp('----------------------------------------------------------------------------')
disp('SMALL-MEDIUM FARMS, MEDIAN REGRESSION')
table(round(beta_ivqr_farm_2(:,3),4),round(beta_ivqr_farm_2(:,8),4),round([beta_ivqr_farm_2(:,3+15),beta_ivqr_farm_2(:,3+20)],4),...
    'VariableNames',{'Coeff','se','Conf_Interval_95'},'RowNames',Names)
pause
disp('----------------------------------------------------------------------------')
disp('MEDIUM-LARGE FARMS, MEDIAN REGRESSION')
table(round(beta_ivqr_farm_3(:,3),4),round(beta_ivqr_farm_3(:,8),4),round([beta_ivqr_farm_3(:,3+15),beta_ivqr_farm_3(:,3+20)],4),...
    'VariableNames',{'Coeff','se','Conf_Interval_95'},'RowNames',Names)
pause
disp('----------------------------------------------------------------------------')
disp('LARGE FARMS, MEDIAN REGRESSION')
table(round(beta_ivqr_farm_4(:,3),4),round(beta_ivqr_farm_4(:,8),4),round([beta_ivqr_farm_4(:,3+15),beta_ivqr_farm_4(:,3+20)],4),...
    'VariableNames',{'Coeff','se','Conf_Interval_95'},'RowNames',Names)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
